class SystemSymbol
   
  # Attributes
  attr_reader :mfc_class_name
  attr_reader :mfc_class_schema

  attr_accessor :data
  attr_reader :position
  attr_reader :system

  # Constants
  DEFAULT_SYSTEM = 0
  DEFAULT_POSITION = 0
  DEFAULT_DATA = 0
  
  MIN_SYSTEM = 0
  MAX_SYSTEM = 65535
  
  MIN_POSITION = 0
  MAX_POSITION = 255
   
  # Constructor   
  def initialize(system = DEFAULT_SYSTEM, position = DEFAULT_POSITION, data = DEFAULT_DATA)    

    mfc_class_name = "CSectionSymbol"
    mfc_class_schema = 1

    return false unless valid_system?(system)
    return false unless valid_position?(position) 
    
    system=(system)
    position=(position)
  end
   
  # Methods
  def valid_system?(system)
    return ((system >= MIN_SYSTEM) && (system <= MAX_SYSTEM))
  end
      
  def system=(system)
    return false unless valid_system?(system)
    @system = system
    return true
  end
  
  def valid_position?(position)
    return ((position >= MIN_POSITION) && (position <= MAX_POSITION))
  end
      
  def position=(position)
    return false unless valid_position?(position)
    @position = position
    return true
  end
            
  # Serialization  
  def do_serialize(stream)  
    write_word(stream, @system)
    write_byte(stream, @position)
    write_integer(stream, @data)
    return true
  end

  def do_deserialize(stream)
    @system = read_word(stream)
    @position = read_byte(stream)
    @data = read_integer(stream)
  end

end
